public class J07Array {
    public static void main(String[] args) {
        //存储5个年龄
        int[] ages = {1,3,5,7,8};
        //下标，0,1,2,3,4
        //数组元素读取
        System.out.println(ages[0]);//1
        System.out.println(ages[3]);//7
        //修改
        ages[1] = 0;
        System.out.println("ages[1] = " + ages[1]);
        //读出来，赋值给另一个变量
        int m = ages[4];
        System.out.println("m = " + m);

        System.out.println("=======");
        long lArr[] = {3,5,8};
        System.out.println(lArr[2]);

    }
}
class Arr2Test{
    public static void main(String[] args) {
        //初始化
        //动态初始化，默认值全是0
        int[] scoreArr = new int[5];

        System.out.println(scoreArr[0]);
        System.out.println(scoreArr[1]);
        System.out.println(scoreArr[2]);

        boolean[] blArr = new boolean[3];
        System.out.println(blArr[0]);//false

        //引用
        //Scanner/Random /String
        //元素
        String s = "abc";
        String[] sArr = new String[3];
        sArr[1]="xyz";
        System.out.println(sArr[0]);
        System.out.println(sArr[1]);



        //静态初始化
        //简写
        int[] arr1 = {3,5,7};
        //完整写法
        int[] arr2 = new int[]{5,7,9,2};

        System.out.println(arr2[2]);//9

        int sum = arr2[0] + arr2[1];
        System.out.println(sum);//12
    }
}
